home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / PAC-GEN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1999-07-24  |  3.8 KB  |  130 lines

  1. //******************************************************************
  2. //*             solution for Kwazy Webbit's PacMe Crackme          *
  3. //*                   solved By Nuno1 on 24 july 1999              *
  4. //*           any comments can be sent to nuno_2@hotmail.com       *
  5. //******************************************************************
  6.  
  7. // this is a KeyFile Generator.
  8.  
  9. #include <string.h>
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12.  
  13. #define FILENAME "KwazyWeb.bit" //the file to create the KeyFile.
  14.  
  15. //a tables of moves for the MAZE.
  16. //there is only up , down , left , right possiblitys ;)
  17. //here is the table :
  18. //-----------
  19. //|0|  Up   |
  20. //|1| Right |
  21. //|2| Down  |
  22. //|3| Left  |
  23. //-----------
  24.  
  25. const char MAZEMOVES[18*4] =  {2,2,2,1,2,2,2,3,2,2,1,
  26.                                1,0,1,0,0,1,1,1,0,0,3,
  27.                                3,3,0,3,0,0,1,1,1,1,1,
  28.                                2,1,1,0,1,1,2,1,1,1,2,
  29.                                2,3,3,2,3,3,0,3,3,2,2,
  30.                                2,3,2,2,1,1,1,0,0,1,1,
  31.                                1,1,2,2,3,3};
  32.  
  33. //**********************************************//
  34. //        Print a logo for the program
  35. //**********************************************//
  36.  
  37. void PrintLogo() {
  38.     printf("************************************************\n");
  39.     printf("    solution for Kwazy Webbit's PacMe Crackme   \n");
  40.     printf("         solved By Nuno1 on 22 july 1999        \n");
  41.     printf(" any comments can be sent to nuno_2@hotmail.com \n");
  42.     printf("************************************************\n");
  43. }
  44.  
  45. //********************************//
  46. //          Main Program          //
  47. //********************************//
  48.  
  49. void main(int argc,char **argv) {
  50.  
  51.     char UserName[50]; //this variable will hold the user name from
  52.                         //the arguments.
  53.     unsigned char Numbers[0x1c];
  54.  
  55.     char Step1,Step2,Step3,Step4;
  56.  
  57.     long UserNameTotal = 0;
  58.  
  59.     FILE *f;
  60.     int t;
  61.  
  62.     //Print The Logo.
  63.     PrintLogo();
  64.  
  65.     for(t=0;t<50;t++)
  66.         UserName[t] = 0;
  67.     if (argc == 1) {    //checking if there paramaters are entered.
  68.         //if no .. we print the syntax of the program
  69.         //(argv[0] is the application executeble file)
  70.         printf("syntax : %s <Your Registration Name>\n",argv[0]);
  71.         //exit from the program.
  72.         exit(-1);
  73.     }
  74.     else
  75.     {
  76.         //if paramaters been prompt we cut them all to one string
  77.         //with " " seperate .. because the name can be with spaces.
  78.         for(t=1;t<=argc-1;t++) {
  79.             strcat(UserName,argv[t]);
  80.             if (t != argc-1)
  81.                 strcat(UserName," ");
  82.         }
  83.     }
  84.  
  85.     //here we calculate the username total.
  86.     for(t=0;t<=strlen(UserName);t++) {
  87.         UserNameTotal = UserNameTotal + UserName[t];
  88.     }
  89.     //this is the encryption method for the steps.. used our total ofcourse.
  90.  
  91.     //the 0x12 is really the numbers of steps we have to do .. but
  92.     //it is multiply with 4 because each byte represet 4 steps.
  93.     for(t=0;t<0x12;t++) {
  94.  
  95.         //Step 1 is the most left 2 bits
  96.         Step1 = MAZEMOVES[t*4]   << 6;
  97.         //Step 2 is the second left 2 bits
  98.         Step2 = MAZEMOVES[t*4+1] << 4;
  99.         //Step 3 is the second right 2 bits
  100.         Step3 = MAZEMOVES[t*4+2] << 2;
  101.         //Step 4 is the first right 2 bits.
  102.         Step4 = MAZEMOVES[t*4+3];
  103.  
  104.         //after we build the 4 steps into we add it to one byte.
  105.         Numbers[t] = Step1+Step2+Step3+Step4;
  106.         //Xor it with the Total of the username (this is the encryption)
  107.         Numbers[t] = Numbers[t] ^ (char)UserNameTotal;
  108.     }
  109.     //now we write the file.
  110.  
  111.     //open the file and check if its open.
  112.     if ((f = fopen(FILENAME,"wb")) == NULL) {
  113.         printf("Error write file %s !!! ",FILENAME);
  114.         exit(-1);
  115.     }
  116.     //t = string length of username.
  117.     t = strlen(UserName);
  118.     //write he first byte as the length of the string.
  119.     fwrite(&t,1,1,f);
  120.     //write the username
  121.     fwrite(&UserName,t,1,f);
  122.     //and write the encrypted steps.
  123.     fwrite(&Numbers,0x12,1,f);
  124.     //close the file
  125.     fclose(f);
  126.     printf("\nthe file %s as been generated for %s.\n",FILENAME,&UserName);
  127.  
  128. }
  129. //end of the program
  130.